/**
 * 
 */
package com.wsj.web.action.researchReport;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.wsj.service.IHomeSiteNewsServ;
import com.wsj.service.IHomeSiteResearchReportFileUploadServ;
import com.wsj.util.page.PageResultSet;
import com.wsj.util.tool.NumberUtil;
import com.wsj.web.action.BaseAction;
import com.wsj.web.constant.homeSiteNews.HomeSiteNewsConstant;
import com.wsj.web.constant.homeSiteNews.IndexPageContent;
import com.wsj.web.constant.page.PageContent;
import com.wsj.web.subclass.displayBean.HomeSiteNews.HomeSiteIndexPageColumnBean;
import com.wsj.web.vo.homeSite.HomeSiteUploadFile;

/**
 * @author fengbin  createTime:2009-7-28
 *
 */
public class ResearchReportSearchAction extends BaseAction {
	
	/*********
	 * 研究报告上传服务层
	 */
	 private IHomeSiteResearchReportFileUploadServ homeSiteResearchReportFileUploadServ;
	 
	 
	/** 资讯接口 */
	private IHomeSiteNewsServ homeSiteNewsServ;
	 
	/***********
	 * 获取研究报告列表
	 * 
	 * 通过  文件名  文件类型  研究机构  发布开始时间 发布结束时间 搜索研究报告  
	 */
	@SuppressWarnings("unchecked")
	public ActionForward list(ActionMapping mapping, ActionForm form, HttpServletRequest request,
			HttpServletResponse response) throws Exception { 
		
		   String pageStr = request.getParameter("page");
		   String pageSizeStr  = request.getParameter("pageSize");
		   int page = HomeSiteNewsConstant.DEFAULT_PAGE;
		   int pageSize = HomeSiteNewsConstant.DEFAULT_PAGE_SIZE;
		   
		   //"keyword","isDel","institutionId","reportType"
		   
		   if(pageStr!=null  && !pageStr.equals("") && !NumberUtil.isNumber(pageStr)){
			   page = Integer.valueOf(pageStr);
		   }
		   
		   
		   if(pageSizeStr!=null  && !pageSizeStr.equals("") && !NumberUtil.isNumber(pageSizeStr)){
			   pageSize = Integer.valueOf(pageSizeStr);
		   }
		   
		   
		   //获取左边的推荐的新闻
		   getLeftPageCommentNews(request);
		   
		   PageResultSet pageResultSet = this.getHomeSiteResearchReportFileUploadServ().getAllResearchReportList(page,pageSize);
		   
		   if(pageResultSet!=null)
			{
			  	// 设置上一页
				request.setAttribute(PageContent.backPage,pageResultSet.getBackPage());
				//下一页
				request.setAttribute(PageContent.nextPage,pageResultSet.getNextPage());
				//当前页
				request.setAttribute(PageContent.curPage,pageResultSet.getCurPage());
				
				//总共页数
				request.setAttribute(PageContent.allPage,pageResultSet.getAllPage());
				//大小
				request.setAttribute(PageContent.pageSize,pageResultSet.getPageSize());
				
				request.setAttribute(PageContent.recordNum, pageResultSet.getRecordNum());
				
				//结果集
				List<HomeSiteUploadFile> homeSiteUploadFileList = pageResultSet.getResult();
				request.setAttribute("homeSiteUploadFileList", homeSiteUploadFileList);
				
			}
		   
		   //跳转到研究报告列表页面
		   return mapping.findForward("researchReportFileList");
	}
	
	
	
	
	/**********
	 * 获取左边推荐新闻
	 * @param request
	 */ 
	private void getLeftPageCommentNews(HttpServletRequest request) {
		
		//列表页 左边推荐新闻  10条文本新闻 0条图片新闻 0条引导阅读新闻
		HomeSiteIndexPageColumnBean COLUMN_SEARCH_COMMEND_NEWS_1 = this.homeSiteNewsServ.getColumnNews(IndexPageContent.SEARCH_COMMEND_NEWS_1_NAME,6,0,IndexPageContent.GUIDE_NEWS_DISPLAY_NO);
		request.setAttribute("COLUMN_SEARCH_COMMEND_NEWS_1", COLUMN_SEARCH_COMMEND_NEWS_1);
		
		//列表页 左边推荐新闻  10条文本新闻 0条图片新闻 0条引导阅读新闻
		HomeSiteIndexPageColumnBean COLUMN_SEARCH_COMMEND_NEWS_2 = this.homeSiteNewsServ.getColumnNews(IndexPageContent.SEARCH_COMMEND_NEWS_2_NAME,6,0,IndexPageContent.GUIDE_NEWS_DISPLAY_NO);
		request.setAttribute("COLUMN_SEARCH_COMMEND_NEWS_2", COLUMN_SEARCH_COMMEND_NEWS_2);
		
		
		
	}

	
	

	public IHomeSiteResearchReportFileUploadServ getHomeSiteResearchReportFileUploadServ() {
		return homeSiteResearchReportFileUploadServ;
	}

	public void setHomeSiteResearchReportFileUploadServ(
			IHomeSiteResearchReportFileUploadServ homeSiteResearchReportFileUploadServ) {
		this.homeSiteResearchReportFileUploadServ = homeSiteResearchReportFileUploadServ;
	}




	public IHomeSiteNewsServ getHomeSiteNewsServ() {
		return homeSiteNewsServ;
	}




	public void setHomeSiteNewsServ(IHomeSiteNewsServ homeSiteNewsServ) {
		this.homeSiteNewsServ = homeSiteNewsServ;
	}
	
	
	
	

}
